package com.three.lab.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.three.lab.R;
import com.three.lab.bean.ClassifyChildBean;

import java.util.List;

public class ClassifyChildAdapter extends BaseQuickAdapter<ClassifyChildBean, BaseViewHolder> {
    public ClassifyChildAdapter(@Nullable List<ClassifyChildBean> data) {
        super(R.layout.item_list_classify_child, data);
    }

    public ClassifyChildAdapter() {
        super(R.layout.item_list_classify_child);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ClassifyChildBean item) {
        helper.setText(R.id.tv_type,item.getPname())
        .addOnClickListener(R.id.ll_more);

        RecyclerView recyclerView = helper.getView(R.id.rv_goods);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext,3));
        ClassifyGoodsAdapter goodsAdapter = new ClassifyGoodsAdapter();
        recyclerView.setAdapter(goodsAdapter);
        goodsAdapter.setNewData(item.getGoodsBeanList());
    }
}
